home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / MT2ToolKit 1.0b1 / Trivial / Example / test ƒ / test.p < prev    next >
Encoding:
Text File  |  1995-10-08  |  12.1 KB  |  522 lines  |  [TEXT/MPS ]

  1. {**********************************************************************
  2.             WARNING!
  3.             This source had been generated by
  4.             beta version of the Trivial MPW Tool.
  5.             Be sure to ask author about improved version of Trivial
  6.             (other MPW tools&scripts are also available) :
  7.                             Michael I Trofimov,
  8.                             Internet: mtrofimov@glas.apc.org
  9.             (Any comments & suggestions will be highly appreciated.)
  10. **********************************************************************}
  11. {%% Generation option: -h}
  12. program test;
  13. { CONST Version  = '1.0';   For 'vers' resource}
  14.  USES Memory,Quickdraw,Events,Desk,ToolUtils,Windows,Menus,Dialogs
  15. {%% >> add necessary units here <<}
  16. ;
  17. {
  18. ,ActionAtomIntf,ADSP,AEObjects,AEPackObject,AERegistry,AIFF,Aliases,AppleEvents,AppleTalk
  19. ,Balloons
  20. ,CommResources,Components,Connections,ConnectionTools,Controls,CRMSerialDevices,CTBUtilities
  21. ,CursorCtl
  22. ,DatabaseAccess,DeskBus,Devices,DisAsmLookup,DiskInit,Disks
  23. ,Editions,ENET,EPPC,ErrMgr,Errors
  24. ,Files,FileTransfers,FileTransferTools,Finder,FixMath,Folders,Fonts
  25. ,GestaltEqu,Graf3D
  26. ,HyperXCmd
  27. ,Icons,ImageCodec,ImageCompression,IntEnv
  28. ,Language,Lists
  29. ,MacPrint,MediaHandlers,Memory,MemTypes,MIDI,Movies,MoviesFormat
  30. ,Notification
  31. ,ObjIntf,OSEvents,OSIntf,OSUtils
  32. ,Packages,PackIntf,PaletteMgr,Palettes,PasLibIntf,Perf,Picker,PickerIntf,PictUtil
  33. ,Power,PPCToolBox,Printing,PrintTraps,Processes
  34. ,QDOffscreen,QuickTimeComponents
  35. ,Resources,Retrace,ROMDefs,RTLib
  36. ,SANE,Scrap,Script,SCSI,SCSIIntf,SegLoad,Serial,ShutDown,Signal,Slots,Sound,SoundInput
  37. ,StandardFile,Start,Strings,SysEqu
  38. ,Terminals,TerminalTools,TextEdit,Timer,ToolIntf,Traps,Types
  39. ,Unmangler
  40. ,Video,VideoIntf
  41. }
  42.  
  43.  CONST
  44.   CNTLID130 = 130; {%%?}
  45.   CNTLID129 = 129; {%%?}
  46.   NewWindowWINDID = 128; { WIND resource : New Window }
  47.   FileMENUID = 257; { MENU resource : File }
  48.   NewItem =  1; { "New" }
  49.   OpenItem =  2; { "Open…" }
  50.   CloseItem =  3; { "Close" }
  51.   SaveItem =  5; { "Save" }
  52.   SaveasItem =  6; { "Save as…" }
  53.   PageSetupItem =  8; { "Page Setup…" }
  54.   PrintItem =  9; { "Print…" }
  55.   QuitItem = 11; { "Quit" }
  56.   EditMENUID = 258; { MENU resource : Edit }
  57.   UndoItem =  1; { "Undo" }
  58.   CutItem =  3; { "Cut" }
  59.   CopyItem =  4; { "Copy" }
  60.   PasteItem =  5; { "Paste" }
  61.   ClearItem =  6; { "Clear" }
  62.   SelectAllItem =  7; { "Select All" }
  63.   AppleMENUID = 256; { MENU resource : Apple }
  64.   AbouttestEditItem =  1; { "About testEdit…" }
  65.   MBARID = 128;
  66.   D128OkItem = 1; { Ok }
  67.   D128CancelItem = 2; { Cancel }
  68.   D128Item3 = 3; {  }
  69.   D128Item4 = 4; {  }
  70.   D128Item5 = 5; {  }
  71.   D128DoitItem = 6; { Do it }
  72.   D128HiItem = 7; { Hi }
  73.   D128LoItem = 8; { Lo }
  74.   D128PictureItem9 = 9; {  }
  75.   D128IconItem10 = 10; {  }
  76.   D128Item11 = 11; {  }
  77.   D128AnyTextItem = 12; { Any Text }
  78.   D129OkItem = 1; { Ok }
  79.   D129CancelItem = 2; { Cancel }
  80.   D129UserItemItem3 = 3; {  }
  81.   D129PleaseselectfilefromlistItem = 4; { Please, select file from list. }
  82.   D130OkItem = 1; { Ok }
  83.   D130TextinalertboxItem = 2; { Text in alert box }
  84.   a1stDialogDLOGID = 128; { DLOG resource : 1st Dialog }
  85.   a2ndDialogDLOGID = 129; { DLOG resource : 2nd Dialog }
  86.   ICONID128 = 128; {%%?}
  87.   PICTID128 = 128; {%%?}
  88.   MyalertboxALRTID = 130; { ALRT resource : My alert box }
  89.  
  90. {%% Generation option: -i}
  91.  
  92.  PROCEDURE  DoNewItem;
  93.   begin { DoNewItem }
  94.  
  95.   end; { DoNewItem }
  96.  
  97.  PROCEDURE  DoOpenItem;
  98.   begin { DoOpenItem }
  99.  
  100.   end; { DoOpenItem }
  101.  
  102.  PROCEDURE  DoCloseItem;
  103.   begin { DoCloseItem }
  104.  
  105.   end; { DoCloseItem }
  106.  
  107.  PROCEDURE  DoSaveItem;
  108.   begin { DoSaveItem }
  109.  
  110.   end; { DoSaveItem }
  111.  
  112.  PROCEDURE  DoSaveasItem;
  113.   begin { DoSaveasItem }
  114.  
  115.   end; { DoSaveasItem }
  116.  
  117.  PROCEDURE  DoPageSetupItem;
  118.   begin { DoPageSetupItem }
  119.  
  120.   end; { DoPageSetupItem }
  121.  
  122.  PROCEDURE  DoPrintItem;
  123.   begin { DoPrintItem }
  124.  
  125.   end; { DoPrintItem }
  126.  
  127.  PROCEDURE  DoQuitItem;
  128.   begin { DoQuitItem }
  129.  
  130.   end; { DoQuitItem }
  131.  
  132.  PROCEDURE  DoUndoItem;
  133.   begin { DoUndoItem }
  134.  
  135.   end; { DoUndoItem }
  136.  
  137.  PROCEDURE  DoCutItem;
  138.   begin { DoCutItem }
  139.  
  140.   end; { DoCutItem }
  141.  
  142.  PROCEDURE  DoCopyItem;
  143.   begin { DoCopyItem }
  144.  
  145.   end; { DoCopyItem }
  146.  
  147.  PROCEDURE  DoPasteItem;
  148.   begin { DoPasteItem }
  149.  
  150.   end; { DoPasteItem }
  151.  
  152.  PROCEDURE  DoClearItem;
  153.   begin { DoClearItem }
  154.  
  155.   end; { DoClearItem }
  156.  
  157.  PROCEDURE  DoSelectAllItem;
  158.   begin { DoSelectAllItem }
  159.  
  160.   end; { DoSelectAllItem }
  161.  
  162.  PROCEDURE  DoAbouttestEditItem;
  163.   begin { DoAbouttestEditItem }
  164.  
  165.   end; { DoAbouttestEditItem }
  166.  
  167.  PROCEDURE  DoD128OkItem;
  168.   begin { DoD128OkItem }
  169.  
  170.   end; { DoD128OkItem }
  171.  
  172.  PROCEDURE  DoD128CancelItem;
  173.   begin { DoD128CancelItem }
  174.  
  175.   end; { DoD128CancelItem }
  176.  
  177.  PROCEDURE  DoD128Item3;
  178.   begin { DoD128Item3 }
  179.  
  180.   end; { DoD128Item3 }
  181.  
  182.  PROCEDURE  DoD128Item4;
  183.   begin { DoD128Item4 }
  184.  
  185.   end; { DoD128Item4 }
  186.  
  187.  PROCEDURE  DoD128Item5;
  188.   begin { DoD128Item5 }
  189.  
  190.   end; { DoD128Item5 }
  191.  
  192.  PROCEDURE  DoD128DoitItem;
  193.   begin { DoD128DoitItem }
  194.  
  195.   end; { DoD128DoitItem }
  196.  
  197.  PROCEDURE  DoD128HiItem;
  198.   begin { DoD128HiItem }
  199.  
  200.   end; { DoD128HiItem }
  201.  
  202.  PROCEDURE  DoD128LoItem;
  203.   begin { DoD128LoItem }
  204.  
  205.   end; { DoD128LoItem }
  206.  
  207.  PROCEDURE  DoD128PictureItem9;
  208.   begin { DoD128PictureItem9 }
  209.  
  210.   end; { DoD128PictureItem9 }
  211.  
  212.  PROCEDURE  DoD128IconItem10;
  213.   begin { DoD128IconItem10 }
  214.  
  215.   end; { DoD128IconItem10 }
  216.  
  217.  PROCEDURE  DoD128Item11;
  218.   begin { DoD128Item11 }
  219.  
  220.   end; { DoD128Item11 }
  221.  
  222.  PROCEDURE  DoD128AnyTextItem;
  223.   begin { DoD128AnyTextItem }
  224.  
  225.   end; { DoD128AnyTextItem }
  226.  
  227.  PROCEDURE  DoD129OkItem;
  228.   begin { DoD129OkItem }
  229.  
  230.   end; { DoD129OkItem }
  231.  
  232.  PROCEDURE  DoD129CancelItem;
  233.   begin { DoD129CancelItem }
  234.  
  235.   end; { DoD129CancelItem }
  236.  
  237.  PROCEDURE  DoD129UserItemItem3;
  238.   begin { DoD129UserItemItem3 }
  239.  
  240.   end; { DoD129UserItemItem3 }
  241.  
  242.  PROCEDURE  DoD129PleaseselectfilefromlistItem;
  243.   begin { DoD129PleaseselectfilefromlistItem }
  244.  
  245.   end; { DoD129PleaseselectfilefromlistItem }
  246.  
  247.  PROCEDURE  DoD130OkItem;
  248.   begin { DoD130OkItem }
  249.  
  250.   end; { DoD130OkItem }
  251.  
  252.  PROCEDURE  DoD130TextinalertboxItem;
  253.   begin { DoD130TextinalertboxItem }
  254.  
  255.   end; { DoD130TextinalertboxItem }
  256.  
  257.  
  258. {%% Generation option: -w}
  259.  
  260.  PROCEDURE  DoNewWindow (var window : WindowPtr);
  261.   begin {DoNewWindow}
  262.  
  263.    window := nil;
  264.    window := GetNewWindow (NewWindowWINDID,nil,WindowPtr(-1)); {%%? >> GetNewCWindow << }
  265.  end; {DoNewWindow}
  266.  
  267. {%% Generation options: -a -d}
  268.  
  269.  PROCEDURE  DoD128;
  270.  VAR
  271.   itemHit : integer;
  272.   DialogW : DialogPtr;
  273.   begin { DoD128 }
  274.  
  275.    DialogW := GetNewDialog (a1stDialogDLOGID,nil, pointer (-1));
  276.    REPEAT
  277.     ModalDialog (nil, itemHit); {%% >> Change it for modless dialog <<}
  278.     case itemHit of
  279.       D128OkItem : DoD128OkItem;
  280.       D128CancelItem : DoD128CancelItem;
  281.       D128Item3 : DoD128Item3;
  282.       D128Item4 : DoD128Item4;
  283.       D128Item5 : DoD128Item5;
  284.       D128DoitItem : DoD128DoitItem;
  285.       D128HiItem : DoD128HiItem;
  286.       D128LoItem : DoD128LoItem;
  287.       D128PictureItem9 : DoD128PictureItem9;
  288.       D128IconItem10 : DoD128IconItem10;
  289.       D128Item11 : DoD128Item11;
  290.       D128AnyTextItem : DoD128AnyTextItem;
  291.      end; {case}
  292.    UNTIL itemHit = D128OkItem; {%%?}
  293.    DisposeDialog (DialogW);
  294.  end; { DoD128 }
  295.  
  296.  PROCEDURE  DoD129;
  297.  VAR
  298.   itemHit : integer;
  299.   DialogW : DialogPtr;
  300.   begin { DoD129 }
  301.  
  302.    DialogW := GetNewDialog (a2ndDialogDLOGID,nil, pointer (-1));
  303.    REPEAT
  304.     ModalDialog (nil, itemHit); {%% >> Change it for modless dialog <<}
  305.     case itemHit of
  306.       D129OkItem : DoD129OkItem;
  307.       D129CancelItem : DoD129CancelItem;
  308.       D129UserItemItem3 : DoD129UserItemItem3;
  309.       D129PleaseselectfilefromlistItem : DoD129PleaseselectfilefromlistItem;
  310.      end; {case}
  311.    UNTIL itemHit = D129OkItem; {%%?}
  312.    DisposeDialog (DialogW);
  313.  end; { DoD129 }
  314.  
  315.  PROCEDURE  DoD130;
  316.  VAR
  317.   itemHit : integer;
  318.   begin { DoD130 }
  319.  
  320.    itemHit := Alert (MyalertboxALRTID, nil);
  321.     case itemHit of
  322.       D130OkItem : DoD130OkItem;
  323.       D130TextinalertboxItem : DoD130TextinalertboxItem;
  324.      end; {case}
  325.  end; { DoD130 }
  326.  
  327.  
  328. {%% Generation option: -m}
  329.  
  330. PROCEDURE DoMenuCommand(event: EventRecord; var quit : Boolean);
  331.  
  332. VAR
  333.   menuResult: longint;
  334.   menu,mitem: integer;
  335.  
  336. BEGIN
  337.   menuResult:=MenuSelect(event.where);
  338.   menu:=HiWord(menuResult);
  339.   mitem:=LoWord(menuResult);
  340.   
  341.   CASE menu OF
  342.   FileMENUID : case mitem of
  343.       NewItem : DoNewItem;
  344.       OpenItem : DoOpenItem;
  345.       CloseItem : DoCloseItem;
  346.       SaveItem : DoSaveItem;
  347.       SaveasItem : DoSaveasItem;
  348.       PageSetupItem : DoPageSetupItem;
  349.       PrintItem : DoPrintItem;
  350.       QuitItem : DoQuitItem;
  351.      end; {case}
  352.   EditMENUID : case mitem of
  353.       UndoItem : DoUndoItem;
  354.       CutItem : DoCutItem;
  355.       CopyItem : DoCopyItem;
  356.       PasteItem : DoPasteItem;
  357.       ClearItem : DoClearItem;
  358.       SelectAllItem : DoSelectAllItem;
  359.      end; {case}
  360.   AppleMENUID : case mitem of
  361.       AbouttestEditItem : DoAbouttestEditItem;
  362.      end; {case}
  363.      end; {case}
  364.  end; { DoDoMenuCommand }
  365.  
  366.  
  367. {%% Generation option: -m}
  368.  
  369. PROCEDURE DoMakeMenus;
  370.     var
  371.         menuBar: Handle;
  372.     
  373.     BEGIN
  374.       menuBar:=GetNewMBar(MBARID); {read menus and menu bar}
  375.     
  376.       IF menuBar<>NIL
  377.         THEN
  378.           BEGIN
  379.             SetMenuBar(menuBar); {insert menus into the current menu list}
  380.             DisposHandle(menuBar);
  381.             AddResMenu(GetMHandle(  AppleMENUID),'DRVR'); {add desktop items in Apple Menu
  382.                                                    Items folder to Apple menu}
  383.                                                 
  384.             {%% >> adjust items and enabled state of menus <<}
  385.             
  386.             DrawMenuBar; {draw the menu bar}
  387.     
  388.           END;
  389.     END; {DoMakeMenus}
  390.  
  391. {%% Generation option: -l}
  392.  
  393.   PROCEDURE DoOSEvent(event: EventRecord; VAR cursorRgn: RgnHandle);
  394.   {Handling operating-system events}
  395.  
  396.     VAR
  397.       window: windowPtr;
  398.       activate: boolean;
  399.  
  400.     BEGIN
  401.       window:=FrontWindow;
  402.       CASE BSR(event.message,24) OF
  403.        mouseMovedMessage:
  404.        
  405.                {%% >> Adjust cursor <<}; 
  406.                 
  407.         suspendResumeMessage:
  408.           BEGIN
  409.             activate:=(BAnd(event.message,resumeFlag)<>0);
  410.             
  411.            {%% >> activate appl. window <<};
  412.            
  413.           END;
  414.         OTHERWISE;
  415.       END;
  416.     END; {DoOSEvent}
  417.  
  418. PROCEDURE DoMouseDown (event: EventRecord; var quit : Boolean);
  419.     VAR
  420.      part         : integer;
  421.      aWindow     : WindowPtr;
  422.      
  423.     BEGIN
  424.       part:=FindWindow(event.where,aWindow);
  425.       CASE part OF
  426.         inMenuBar:      DoMenuCommand(event,quit);    
  427.         InSysWindow:     SystemClick(event,aWindow);
  428.         
  429.         inDrag:         {%% >> <<};
  430.         inGoAway:         {%% >> <<};
  431.         inGrow:          {%% >> <<};
  432.         
  433.         inZoomIn, 
  434.         inZoomOut:         {%% >> handle mouse down in zoombox region <<};
  435.         
  436.         inContent:        {%% >> <<};
  437.       END; {case part of}
  438.     END; {DoMouseDown}
  439.  
  440.   PROCEDURE MainLoop;
  441.  
  442.     CONST
  443.       kReturnKey = $0D;
  444.       kEnterKey = $03;
  445.       kEscKey = 27;
  446.       
  447.  
  448.     VAR
  449.       key: Char;
  450.       quit,gotEvent,activate : Boolean;
  451.       event: EventRecord;
  452.       cursorRgn: RgnHandle;
  453.  
  454.     BEGIN
  455.       cursorRgn:=NewRgn;
  456.       quit:=false;
  457.       REPEAT
  458.         gotEvent:=WaitNextEvent(everyEvent,event,15,cursorRgn);
  459.         IF gotEvent
  460.           THEN
  461.             CASE event.what OF
  462.               osEvt: DoOSEvent(event,cursorRgn);
  463.               activateEvt: 
  464.                 BEGIN
  465.                   activate:=BAnd(event.modifiers,activeFlag)<>0;
  466.                           {%% >> <<}
  467.                 END;
  468.                 
  469.               updateEvt:     {%% >> <<};
  470.               mouseUp:         {%% >> <<};
  471.  
  472.               mouseDown: DoMouseDown (event,quit);
  473.  
  474.               keyDown,autoKey:
  475.                 BEGIN
  476.                   key:=chr(BAnd(event.message,charCodeMask));
  477.                   IF (BAnd(event.modifiers,cmdKey)<>0)
  478.                     THEN {command key down}
  479.                      {%% >> <<}
  480.                     ELSE IF key IN [chr(kReturnKey),chr(kEnterKey)]
  481.                       THEN {return or enter keys were pressed}
  482.                          {%% >> <<}
  483.                       ELSE IF (key=chr(kEscKey))
  484.                         THEN {esc key was pressed}
  485.                           BEGIN
  486.                            {%% >> <<}
  487.                           END
  488.                          ELSE 
  489.                           {%% >> <<};
  490.                  END;
  491.               diskEvt:              {%% >> <<};
  492.               nullEvent:         {%% >> <<};
  493.             END; {case}
  494.       UNTIL quit;
  495.       DisposeRgn(cursorRgn);
  496.     END; {MainLoop}
  497.  
  498.   PROCEDURE Init;
  499.     BEGIN
  500.       MaxApplZone;
  501.       MoreMasters;
  502.       MoreMasters;
  503.       MoreMasters;
  504.       MoreMasters;
  505.       MoreMasters;
  506.       MoreMasters;
  507.       
  508.       InitGraf(@thePort);
  509.       {InitFonts;}                     {%%?}
  510. InitWindows; InitMenus; InitDialogs(NIL); DoMakeMenus;
  511.       {TEInit;}                        {%%?}
  512.       InitCursor;                     {%%?}
  513.       
  514.       {%% >> add another initialization here <<}
  515.     END; {Init}
  516.     
  517. BEGIN {program body}
  518.  Init;
  519.  MainLoop;
  520. END.
  521.  
  522.